package service

import (
	"guliedu/model"
	"guliedu/repository"
)

type IEduCommentService interface {
	Insert(comment *model.EduComment) error
	SelectByCourseID(courseID string, page, pageSize int) ([]model.EduComment, error)
	SelectAllByCourseID(courseID string) ([]model.EduComment, error)
	SelectAll(page, pageSize int) ([]model.EduComment, error)
	SelectAllCount() (int64, error)
	Delete(id string) error
}

func NewIEduCommentService() IEduCommentService {
	return &EduCommentService{IEduCommentRepository: repository.NewIEduCommentRepository()}
}

type EduCommentService struct {
	IEduCommentRepository repository.IEduCommentRepository
}

func (t *EduCommentService) SelectAllByCourseID(courseID string) ([]model.EduComment, error) {
	return t.IEduCommentRepository.SelectAllByCourseID(courseID)
}

func (t *EduCommentService) SelectAll(page, pageSize int) ([]model.EduComment, error) {
	return t.IEduCommentRepository.SelectAll(page, pageSize)
}

func (t *EduCommentService) Insert(comment *model.EduComment) error {
	return t.IEduCommentRepository.Insert(comment)
}

func (t *EduCommentService) SelectByCourseID(courseID string, page, pageSize int) ([]model.EduComment, error) {
	return t.IEduCommentRepository.SelectByCourseID(courseID, page, pageSize)
}

func (t *EduCommentService) SelectAllCount() (int64, error) {
	return t.IEduCommentRepository.SelectAllCount()
}

func (t *EduCommentService) Delete(id string) error {
	return t.IEduCommentRepository.Delete(id)
}
